var common = require('../../lib/common.js');
var url = require('../../config/url.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 菜单
    menuData: [],
    itemList: ['视频', '图片'],
    // 圈子
    circle: {},
    audit: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getMenus();
  },

  onShow() {
    this.getCircleInfo();
  },
  /**
  * 获取菜单
  */
  getMenus() {
    common.post(url.getOneType, {}, (data) => {
      for (let i in data) {
        data[i].url = [
          '/pages/aritcle_release_video/index?id=' + data[i].id + '&name=' + data[i].name,
          '/pages/aritcle_release/index?id=' + data[i].id + '&name=' + data[i].name
        ]
      }
      this.setData({ menuData: data });
    });
  },

  /**
   * 获取圈子信息
   */
  getCircleInfo() {
    common.post(url.getCircle, {}, (data) => {
      let audit = '';
      switch (data.audit) {
        case 'pass':
          audit = '通过'
          break;
        case 'wait':
          audit = '审核中'
          break;
        case 'nopass':
          audit = '未通过'
          break;
      }

      this.setData({
        audit: audit,
        circle: data
      });
    })
  },
})